<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>UDT Reference</title>
</head>

<body>

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="table2" bgcolor="#99CCFF" bordercolor="#99CCFF">
  <tr>
    <td width="100%"><font face="Verdana" size="2"><i>&nbsp;UDT Reference: UDT 
	Functions</i></font></td>
  </tr>
</table>
<h1 style="margin-bottom: 0"><font face="Verdana" size="4">send</font></h1>
<p><font face="Verdana" size="2">The <b>send </b>method sends out an application 
buffer.</font></p>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="table3" bgcolor="#C0C0C0" bordercolor="#C0C0C0">
  <tr>
    <td width="100%">
    <p style="margin-top: 0; margin-bottom: 0">
    <font size="1" face="Courier New">int send(<br>
&nbsp; UDTSOCKET <font color="#FFFFFF">u</font>,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<br>
&nbsp; const char *<font color="#FFFFFF"><a class="synParam" onclick="showTip(this)">buf</a></font>,&nbsp;
	<br>
&nbsp; int <font color="#FFFFFF"> <a class="synParam" onclick="showTip(this)">len</a></font>,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<br>
&nbsp; int <a class="synParam" onclick="showTip(this)"><font color="#FFFFFF">flags</font>,</a></font></p>
	<p style="margin-top: 0; margin-bottom: 0">
    <font face="Courier New" size="1">&nbsp; int *<font color="#FFFFFF">handle </font>
	= NULL,</font></p>
	<p style="margin-top: 0; margin-bottom: 0">
    <font face="Courier New" size="1">&nbsp; <a href="structure.htm#MEM">UDT_MEM_ROUTINE</a> 
	<font color="#FFFFFF">routine</font>&nbsp;= NULL</font></p>
	<p style="margin-top: 0; margin-bottom: 0">
    <font face="Courier New" size="1">&nbsp; void* <font color="#FFFFFF">context</font>
    = NULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<br>
	);</font></p>
    </td>
  </tr>
</table>
<h4><font face="Verdana" size="2">Parameters</font></h4>
<dl>
	<dt><font face="Verdana"><i><font size="2">u</font></i><font size="2">
	</font></font> </dt>
	<dd><font face="Verdana" size="2">[in] Descriptor identifying a connected 
	socket. </font></dd>
	<dt><font face="Verdana"><i><font size="2">buf</font></i><font size="2">
	</font></font> </dt>
	<dd><font face="Verdana" size="2">[in] Buffer containing the data to be 
	transmitted. </font></dd>
	<dt><font face="Verdana"><i><font size="2">len</font></i><font size="2">
	</font></font> </dt>
	<dd><font face="Verdana" size="2">[in] Length of the data in <i>buf</i>. </font>
	</dd>
	<dt><font face="Verdana"><i><font size="2">flags</font></i><font size="2">
	</font></font> </dt>
	<dd><font face="Verdana" size="2">[in] Ignored. For compatibility use only. </font></dd>
	<dt><font face="Verdana"><i><font size="2">handle</font></i><font size="2">
	</font></font> </dt>
	<dd><font face="Verdana" size="2">[out] Optional. An descriptor to this send call.
	</font></dd>
	<dt><font face="Verdana"><i><font size="2">routine</font></i><font size="2">
	</font></font> </dt>
	<dd><font face="Verdana" size="2">[in] optional. Function used to process the buffer 
	after the sending is finished. </font></dd>
    <dt><font size="2" face="Verdana"><i>context</i></font> </dt>
	<dd><font face="Verdana" size="2">[in] optional. Context parameter to be
      used in the buffer process routine. </font></dd>
</dl>
<h4><font face="Verdana" size="2">Return Values</font></h4>
<p><font face="Verdana" size="2">On success, the actual size of data sent is returned; Otherwise,
UDT::ERROR 
is returned and the specific error information can be retrieved by
<a href="error.htm">getlasterror</a>. When UDT_SNDTIMEO is set to a positive
value, zero will be returned if no data is sent out before the assigned timer
expires.</font></p>
  <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" id="table4" bordercolordark="#C0C0C0" bordercolorlight="#C0C0C0" width="100%">
    <tr>
      <th align="center" bgcolor="#C0C0C0" width="133">
		<font face="Verdana" size="2">Error Code</font></th>
      <th align="center" bgcolor="#C0C0C0" width="812"><b>
      <font face="Verdana" size="2">Comment</font></b></th>
    </tr>
    <tr>
      <td width="133">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		2001</font></td>
      <td width="812">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		connection broken before send is completed.</font></td>
    </tr>
    <tr>
      <td width="133">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		2002</font></td>
      <td width="812">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		<i>u 
		</i>is not connected.</font></td>
    </tr>
    <tr>
      <td width="133">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		5003</font></td>
      <td width="812">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		invalid parameters.</font></td>
    </tr>
    <tr>
      <td width="133">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		5004</font></td>
      <td width="812">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		<i>u</i> 
		is an invalid UDT socket.</font></td>
    </tr>
    <tr>
      <td width="133">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		5010</font></td>
      <td width="812">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		cannot use <i>send</i> in SOCK_DGRAM mode.</font></td>
    </tr>
    <tr>
      <td width="133">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		6001</font></td>
      <td width="812">
      <p style="margin-top: 1; margin-bottom: 1"><font face="Verdana" size="1">
		insufficient buffer size for non-blocking sending.</font></td>
    </tr>
    </table>
<H4><font face="Verdana" size="2">Description</font></H4>
<P><font face="Verdana" size="2">The <b>send </b>method's behavior depends on 
the sending blocking mode and overlapped IO.</font></P>
<P><font face="Verdana" size="2">In regular IO, with blocking mode, the send is 
blocked until there is enough buffer size in the UDT sender's buffer. On 
non-blocking IO, send will return immediately. UDT <b>send</b> either sends all 
the data specified by the length parameter or nothing. However, it is still 
recommended to use a loop to check the return value for future compatibilities.</font></P>
<P><font face="Verdana" size="2">In overlapped IO (when the <i>handle</i> parameter is given), 
a blocking sending waits until all data are sent out, whereas a non-blocking sending 
returns immediately and the data will be sent at background (if there is enough 
buffer). Once the data sending is completed, the function of <i>routine</i> will be 
executed on the data. Note that UDT does not duplicate the <i>context</i>
parameter: it should remain valid until the <i>routine</i> is called, and it
should be released (if necessary) by applications.</font></P>
<P><font face="Verdana" size="2"> The progress
the overlapped <b>send</b> can be queried by using <a href="overlap.htm">getoverlappedresult</a>.</font></P>
<H4><font face="Verdana" size="2">See Also</font></H4>
<P><b><font face="Verdana" size="2"><a href="select.htm">select</a></font></b><font face="Verdana" size="2"><b>, 
<a href="recv.htm">recv</a>, <a href="sendfile.htm">sendfile</a>, <a href="recvfile.htm">recvfile</a>,
</b><a href="overlap.htm"><b>getoverlappedresult</b></a></font></P>

</body>

</html>
